package com.bjut.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.bjut.action.base.BaseAction;
import com.bjut.domain.User;

public class ViewAction extends BaseAction {
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		String msg;
		int id;
		ActionForward af = null;
		String classname = request.getParameter("class").trim();
		System.out.println(classname);
		String id_str = request.getParameter("id");
		System.out.println(id_str);
		if (id_str != null && !id_str.trim().equals("")) {
			id = Integer.parseInt(id_str);

			if (classname.equals("user")) {

			} else if (classname.equals("employee")) {
				if(hrglxtService.getEmployeeDao().get(id)!=null){
				request.setAttribute("employee", hrglxtService.getEmployeeDao()
						.get(id));
				request.setAttribute("detailInfo", hrglxtService
						.getDetailInfoDao().get(id));
				request.setAttribute("departmentList",hrglxtService.getDepartmentDao().findAll());
				request.setAttribute("positionList",hrglxtService.getPositionDao().findAll());
				af = new ActionForward("/employee/viewemployee.jsp");
				}else{
					request.setAttribute("my", "true");
					af = new ActionForward("/addEmployee.do?action=pre");
				}
			} else if (classname.equals("detailInfo")) {

			} else if (classname.equals("department")) {

			} else if (classname.equals("position")) {

			} else if (classname.equals("attendanceInfo")) {

			} else if (classname.equals("candidate")) {

			} else if (classname.equals("rpDetail")) {

			} else if (classname.equals("salary")) {

			} else if (classname.equals("train")) {

			} else if (classname.equals("trainRecord")) {

			}

			request.setAttribute("id", id);

			return af;
		} else {
			return null;
		}
	}
}
